js wait for seconds

144

js wait for time -

function sleep(milliseconds) {
  const start = Date.now();
  while (Date.now() - start < milliseconds);
}

console.log("Hello");
sleep(2000);
console.log("World!");

javascript wait 10 seconds -

setTimeout(function () {
        // ...
    }, 10000);

// or

.then(() => {
  // ...
  ({ timeout: 10000 });
      });

Comments

Submit
0 Comments